Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Week4 필수 과제 #9

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open

[Feat] Week4 필수 과제 #9

wants to merge 16 commits into from

Conversation

gitsuhyun
Copy link
Contributor

Related issue 🛠

Work Description ✏️

  • 작업 내용
  • 3개의 API 연동 (유저 등록, 로그인, 내 취미 조회)
  • API 연동에 따른 뷰/로직 수정
    회원가입
    • userName, password, hobby를 입력받는 구조로 변경
    • 조건 변경 (8자 이하)
    • 조건을 만족하지 않는 경우 화면에 표시 (dialog 사용)
      로그인
    • userName, password를 입력받는 구조로 변경
    • 로그인 실패/성공 시 안내 문구 표시 (toast 메시지 사용)
      내 취미 조회
    • 이메일 표시 부분 -> 내 취미 표시

Screenshot 📸

Screen_recording_20241114_222915.mp4

Uncompleted Tasks 😅

To Reviewers 📢

피드백 뭐든지 환영합니당

@gitsuhyun gitsuhyun self-assigned this Nov 14, 2024
Copy link

@yskim6772 yskim6772 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4주차 과제도 고생하셨습니다 ~~

import kotlinx.serialization.Serializable

@Serializable
data class UserSignUpRequest(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dto 네이밍 형식을 서로 맞춰주면 좋을 것 같아요!

Comment on lines +6 to +8
fun Context.toast(message: String) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toast 확장함수 추가 좋네요!

password = password
),
) { body ->
editor.putString("loginToken", body!!.result.token)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분도 스트링 추출 해볼까요!

fun postUserLogin(
context: Context,
body: UserLoginRequest,
callback: (ResponseUserTokenDto?) -> Unit

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback이 필요한 이유가 혹시 무엇일까요?? 중복된 로직을 제공한다면 불필요할 것 같아요!

Comment on lines +44 to +45
val error = response.message()
Log.e("error", error.toString())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

분기에 따른 에러 메시지가 보여지면 좋을 것 같아요! 지금은 로그인 실패 시 모두 fail_to_login 토스트 메시지가 뜨는 것 같아요!

viewModel: MyViewModel = viewModel()
) {
val context = LocalContext.current
val snackbarHostState = remember { SnackbarHostState() }
val sharedPreferences = context.getSharedPreferences("token", Context.MODE_PRIVATE)
val token = sharedPreferences.getString("loginToken", "").orEmpty()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orEmpty를 붙여주셨군요!

if (response.isSuccessful) {
_userState.value = response.body()
_hobby.value = response.body()?.result?.hobby
Log.d("getUserHobby", response.body().toString())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로그는 확인 후 지워줍시당 ! Timber를 활용해봐도 좋을 것 같아요 ~

Copy link

@yihwanggeun yihwanggeun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전반적으로 잘 짜주신 것 같아요! 근데 함수의 Depth가 길어지거나 분기처리가 많아질 경우에 좀 더 분리가 잘 되어 보이게 수정하면 더 좋을 것 같습니다!

.addInterceptor(loggingInterceptor)
.build()

val retrofit: Retrofit by lazy {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lazy 하게 설정한 것 좋은 것 같아요!

.build()
}

inline fun <reified T> create(): T = retrofit.create(T::class.java)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

처음 보는 코드여서 어떤 코드인지 찾아봤는데 재사용성이 더 좋아진다고하니 좋은 코드인 것 같아요~!

@@ -184,16 +176,19 @@ fun LoginScreen(
WavveLoginButton(
onClick = {
viewModel.onLoginClick(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viewModel의 함수가 중첩돼서 가시성이 조금 떨어지는 것 같아요!
두개 함수를 조금 분리해서 파라미터로 넘기는 방식도 생각해봐주세요!

LaunchedEffect(Unit) {
snackbarHostState.showSnackbar(context.getString(R.string.welcome))
}
viewModel.getUserHobby(token = token)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

직접 실행하는 방법도 좋은데 LaunchedEffect(Unit)을 사용해서 한 번만 불러오는 방법도 생각해주세요!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 하면 리컴포지션시마다 계속 서버 통신 함수를 부르게 될 것 같네요!

Copy link

@jihyunniiii jihyunniiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생했서요! 합동 세미나도 파이팅!!!

Comment on lines +8 to +10
data class ResponseUserHobbyDto(
@SerialName("result")
val result: Result

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

형태가 계속 반복되니 baseResponse를 사용해봐도 좋을 듯 합니다.

Comment on lines 70 to +71
val dispatcher = LocalOnBackPressedDispatcherOwner.current!!.onBackPressedDispatcher
val sharedPreferences = context.getSharedPreferences("token", Context.MODE_PRIVATE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!! 사용은 지양합시다 NPE가 발생할 수 있서요

LaunchedEffect(Unit) {
snackbarHostState.showSnackbar(context.getString(R.string.welcome))
}
viewModel.getUserHobby(token = token)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 하면 리컴포지션시마다 계속 서버 통신 함수를 부르게 될 것 같네요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] week4 필수 과제
4 participants